﻿@model Tasks.UI.Models.Account.EmployeeManageModel
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link href="@Config.GetCssResourcePath("main.css")" rel="stylesheet" type="text/css" />
    <link href="@Config.GetCssResourcePath("table.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-impromptu.3.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            initTable(".tblStyle1");
        })
        //删除
        function deleteEmployee(UserID) {
            $.Msg.confirmDelete(function () {
                $("#UserID").val(UserID);
                goto("delete")
            });


        }
        //禁用
        function disableEmployee(UserID) {
            $("#UserID").val(UserID);
            goto("disable")
        }
        //启用
        function enableEmployee(UserID) {
            $("#UserID").val(UserID);
            goto("enable")
        }
        function showAssign(title, UserID) {
            var url = "/Power/AssignRole?UserID=" + UserID;
            openTab('授权', url, false)
        }

        function goto(act) {
            //if (act == "search")
            //    $("#PageIndex").val("1");

            $("#act").val(act);
            $("form").submit();
        }


    </script>
</head>
<body>
    @using (Html.BeginForm())
    {
        <div id="container">
            <input id="UserID" name="UserID" type="hidden" />
            <input id="act" name="act" type="hidden" />
            @Html.HiddenFor(t => t.PageIndex)
             <div class="navTitle">
                <ul>
                    <li class="Home SecondLast"><a href="index.php">
                        <div class="HomeIcon">
                        </div>
                        <font><font>Home</font></font></a></li><li class="Last"><span><font><font>员工</font></font></span></li>
                </ul>
            </div>
            <h1>
                <font><font class="">查看：</font></font><a href="#" style="color: #005FA3" id="ViewsMenuButton"
                    class="PopDownMenu"><font><font class="">所有员工</font></font><img width="8" height="5"
                        src="/images/arrow_blue.gif" border="0"></a>
            </h1>
            <p class="intro">
                <font><font>你的员工如下。</font><font class="">点击“添加员工”按钮来添加一个新的员工。添加完员工后请为员工分配权限。 </font></font>
            </p>


            <div class="searchBar">
              <div class="box">
                <table>
                    <tr>
                        <td style="width: 60px;" class="c">
                            <label>
                                姓名:</label>
                        </td>
                        <td>
                            @Html.TextBoxFor(t => t.Name)
                            <label>
                                手机:</label>
                            @Html.TextBoxFor(t => t.MobileNo)
                            <input type="button" value="查询" class="btnSearch" onclick="goto('search')" />
                            <a href="javascript:void(0)" onclick="openTab('新增员工','/Account/EditEmployee',true)">
                                新增员工</a>
                        </td>
                    </tr>
                    <tr>
                        <td class="c">
                            <label>
                                部门:</label>
                        </td>
                        <td>
                            @Html.DropDownListExt("DeptID", PageHelper.DeptSelector(Convert.ToInt32(Model.DeptID)))
                        </td>
                    </tr>
                </table>
                <div class="bottom">
                </div>
                </div>
            </div>
            <div class="pageBody">
                <table class="tblStyle1"  style="table-layout: fixed;">
                    <thead>
                        <tr>
                            <th style="width: 10%">
                                状态
                            </th>
                            <th style="width: 10%">
                                姓名
                            </th>
                            <th style="width: 10%">
                                部门
                            </th>
                            <th style="width: 10%">
                                账号
                            </th>
                            <th style="width: 10%">
                                直线
                            </th>
                            <th style="width: 15%">
                                手机
                            </th>
                            <th style="width: 20%">
                                最后登录
                            </th>
                            <th style="width: 15%">
                                操作
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (Employee employee in Model.AccountList)
                        {
                            if (employee.Contact == null)
                            {
                                employee.Contact = new ContactInfo();
                            }
                            <tr>
                                <td class="c">
                                    @employee.EmployeeStateStr()
                                </td>
                                <td class="c">
                                    @employee.Name
                                </td>
                                <td class="c">
                                    @employee.DeptName
                                </td>
                                <td class="c">
                                    @employee.AccountNo
                                </td>
                                <td class="c">
                                    @employee.Contact.Tel
                                </td>
                                <td class="c">
                                    @employee.MobileNo
                                </td>
                                <td class="c">
                                    @employee.LastLoginTime
                                </td>
                                <td class="c">
                                    <input name="UserID" class="UserID" type="hidden" value="@employee.UserID"/>
                                    <a href="javascript:void(0)" onclick="openTab('编辑员工','/Account/EditEmployee?userID=@employee.UserID',true)">
                                        <img src="/images/icon/16x16/file_edit.png" title="编辑" /></a> <a href="javascript:void(0)" onclick="openTab('授权','/Power/AssignUserPower?UserID=@employee.UserID')">
                                            <img src="/images/icon/16x16/key.png" title="授权" /></a> <a href="javascript:void(0)" onclick="showAssign('权限组','@employee.UserID')">
                                                <img src="/images/icon/16x16/group_key.png" title="权限组" /></a>
                                    @if (employee.EmployeeState == 1)
                                    {
                                        <a href="javascript:void(0)" onclick="deleteEmployee(@employee.UserID)">
                                            <img src="/images/icon/16x16/delete.png" title="删除" /></a>
                                        <a href="javascript:void(0)" onclick="disableEmployee(@employee.UserID)">
                                            <img src="/images/icon/16x16/stop.png" title="禁用" /></a>
                                    }
                                    else if (employee.EmployeeState == 2)
                                    {
                                        <a href="javascript:void(0)" onclick="enableEmployee(@employee.UserID)">
                                            <img src="/images/icon/16x16/enable.png" title="启用" /></a>
                                    }
                                    else
                                    {
                                        <a href="javascript:void(0)" onclick="enableEmployee(@employee.UserID)">
                                            <img src="/images/icon/16x16/enable.png" title="启用" /></a>
                                    }
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                @Html.RenderPageNav(Model.PageIndex, Model.PageSize, Model.RowCount, "/Account/EmployeeManage/?PageIndex=#PageIndex#", Tasks.Core.PageNavStyle.Form)
            </div>
        </div>
    }
</body>
</html>
